<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>history</title>
</head>
<body>
    <button id="home">主页</button>
    <button id="news">新闻</button>
</body>
</html>
<script>
    //history模式，主要的核心是利用了H5新增的history Api
    //正常调用pushstate也不会建立http连接，发起请求，但是一旦刷新页面就会造成404问题
    
    home.onclick = function(){
        history.pushState({name:"lilei"},null,'/home')
    }
    news.onclick = function(){
        history.pushState({name:"韩梅梅"},null,'/news')
    }

    //通过popstate事件来处理对应的逻辑
    window.onpopstate = function(e){
        console.log(e);
    }

</script>